package cn.tedu.csmall.passport.controller;

import cn.tedu.csmall.commons.web.JsonResult;
import cn.tedu.csmall.passport.pojo.vo.RoleListItemVO;
import cn.tedu.csmall.passport.service.IRoleService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/roles")
@Api(tags = "02.角色管理模块")
@Slf4j
public class RoleController {

    @Autowired
    private IRoleService roleService;


    // http://localhost:9081/roles
    @GetMapping("")
    @PreAuthorize("hasAuthority('/ams/admin/read')")
    //包含权限，有这个权限才能访问，没有权限不能访问
    @ApiOperation("查询角色列表")
    @ApiOperationSupport(order = 420)

    public JsonResult list() {
      log.debug("开始处理[查询角色列表]的请求，无参数");
        List<RoleListItemVO> list = roleService.list();
        return JsonResult.ok(list);
    }


}
